package com.itheima.day13.thread.test12;

public class Test {
    public static void main(String[] args) {
        Object objA = new Object();
        Object objB = new Object();

        new Thread(() -> {
            System.out.println("舒克进去了");
            while (true) {
                synchronized (objA) {
                    synchronized (objB) {
                        System.out.println("舒克");
                    }
                }
            }
        }).start();
        new Thread(() -> {
            System.out.println("贝塔进去了");
            while (true) {
                synchronized (objB) {
                    System.out.println("贝塔锁了B");
                    synchronized (objA) {
                        System.out.println("贝塔");
                    }
                }
            }
        }).start();
    }
}
